﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;


namespace PhotoGallery.Models.DataContracts
{
    [Serializable, DataContract]
    public class FileNodeOperationDateContract
    {
        /// <summary>
        /// Key
        /// </summary>
        [DataMember(IsRequired = false)]
        public int? Id { get; set; }

        /// <summary>
        /// 如果是移动和添加
        /// </summary>
        [DataMember(IsRequired = false)]
        public int? ParentId { get; set; }

        /// <summary>
        /// 操作
        /// </summary>
        [DataMember(IsRequired = true)]
        public string Operation { get; set; }


        /// <summary>
        /// 设置名称
        /// </summary>
        [DataMember(IsRequired = false)]
        public string Name { get; set; }

    }

    [Serializable, DataContract]
    public class Node
    {
        public Attr attr { get; protected set; }

        public string data { get; protected set; }

        public string state { get; protected set; }

        protected Node()
        {
            this.data = string.Empty;

            this.attr = new Attr();

            this.state = State.closed;
        }


        public Node(string data, string key)
            : this()
        {
            if (string.IsNullOrEmpty(data) || string.IsNullOrEmpty(key))
                throw new ArgumentNullException("the source si null!!!!");

            this.data = data;
            this.attr = new Attr(key, Rel.floder);
            this.state = State.closed;
            this.attr.rel = "driver";

        }


    }

    /// <summary>
    ///  属性
    /// </summary>
    [Serializable, DataContract]
    public class Attr
    {

        #region Field & Property

        public string id { get; set; }

        public string rel { get; set; }

        #endregion
        public Attr()
        {
            this.id = string.Empty;
            this.rel = Rel.file;
        }

        public Attr(string id, string rel)
            : this()
        {
            this.id = string.Format("node_{0}", id);
            this.rel = rel;
        }

        #region Method

        #endregion
    }

    /// <summary>
    /// 图标
    /// </summary>
    [Serializable, DataContract]
    public class Rel
    {
        public const string file = "file";
        public const string floder = "floder";
        public const string drive = "drive";

    }

    /// <summary>
    /// 是否开启
    /// </summary>
    [Serializable, DataContract]
    public class State
    {
        public const string opended = "opended";
        public const string closed = "closed";
    }

    public class LocationDes
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}
